import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store'

/* Layout */
// import {  } from 'zcsd-core/src'
import { APP, Layout } from 'zcsd-core'
Vue.use(Router)
/* Router Modules */
// import componentsRouter from './modules/components'
// import chartsRouter from './modules/charts'
// import tableRouter from './modules/table'
// import nestedRouter from './modules/nested'

/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
export const constantRoutes = [

  {
    path: '/',
    component: Layout,
    redirect: () => store.getters['zcsd-core/permission_routes'][0],
    children: [
      {
        path: '/report',
        component: APP,
        name: 'ReportManage',
        redirect: '/report/overview',
        meta: { title: '数据报表' },
        children: [
          {
            path: 'overview',
            component: () => import('@/views/report/overview'),
            name: 'OverviewReport',
            meta: { title: '数据概览' }
          },
          {
            path: 'logicAnal',
            component: () => import('@/views/report/logicAnal'),
            name: 'LogicAnal',
            meta: { title: '业务分析' }
          },
          {
            path: 'channelAnal',
            component: () => import('@/views/report/channelAnal'),
            name: 'channelAnal',
            meta: { title: '渠道分析' }
          },
          {
            path: 'userAnal',
            component: () => import('@/views/report/userAnal'),
            name: 'UserAnal',
            meta: { title: '用户分析' }
          },
          {
            path: 'pay-use',
            component: () => import('@/views/report/pay-use'),
            name: 'PayUseReport',
            meta: { title: '付费排行' }
          }
        ]
      },
      {
        path: '/feedback',
        component: APP,
        name: 'Feedback',
        meta: { title: '反馈分析' },
        children: [
          {
            path: '/feedback/datareport',
            name: 'DataReport',
            meta: { title: '反馈数据报表' },
            component: () => import('@/views/feedback/dataReport/index')
          },
          {
            path: '/feedback/datahandle',
            name: 'DataHandle',
            meta: { title: '反馈统计与处理' },
            component: () => import('@/views/feedback/dataHandle/index')
          },
          {
            path: '/feedback/taglib',
            name: 'TagLib',
            meta: { title: '反馈标签库' },
            component: () => import('@/views/feedback/tagLib/index')
          },
          {
            path: '/feedback/reason',
            name: 'Reason',
            meta: { title: '用户反馈原因管理' },
            component: () => import('@/views/feedback/reason/index')
          }
        ]
      },
      {
        path: '/feature',
        component: APP,
        name: 'Feature',
        meta: { title: '功能分析' },
        children: [
          {
            path: '/feature/datareport',
            name: 'FeatReport',
            meta: { title: '功能报表' },
            component: () => import('@/views/feature/featReport/index')
          },
          {
            path: '/feature/translate',
            name: 'Translate',
            meta: { title: '翻译统计' },
            component: () => import('@/views/feature/translate/index')
          },
          {
            path: '/feature/report-analysis',
            name: 'ReportAnalysis1',
            meta: { title: '埋点统计' },
            component: () => import('@/views/feature/report-analysis')
          },
          {
            path: '/feature/report-manager',
            name: 'ReportManager',
            meta: { title: '埋点管理' },
            component: () => import('@/views/feature/report-analysis/report-manager/index.vue')
          },
          {
            path: '/feature/report-detail',
            name: 'ReportDetail',
            meta: { title: '埋点详情' },
            component: () => import('@/views/feature/report-analysis/report-detail/index.vue')
          }
        ]
      },
      {
        path: '/dump',
        name: 'DumpStat',
        meta: { title: 'Dump统计' },
        component: () => import('@/views/dump/index')
      },
      {
        path: 'user',
        redirect: '/user/index',
        component: APP,
        name: 'User',
        children: [
          {
            path: 'index',
            name: 'UserList',
            component: () => import('@/views/user/list.vue'),
            meta: { title: '用户列表' }
          },
          {
            path: 'auth',
            name: 'UserAuth',
            component: () => import('@/views/user/auth.vue'),
            meta: { title: '用户审核' }
          }
        ]
      },
      {
        path: 'task',
        redirect: '/task/index',
        component: APP,
        name: 'Task',
        children: [
          {
            path: 'index',
            name: 'TaskList',
            component: () => import('@/views/task/list.vue'),
            meta: { title: '任务列表' }
          },
          {
            path: 'sort',
            name: 'TaskSort',
            component: () => import('@/views/task/sort.vue'),
            meta: { title: '任务分类' }
          }
        ]
      },
      {
        path: 'level/index',
        component: () => import('@/views/level/index'),
        name: 'Level',
        meta: { title: '会员等级管理' }
      },
      {
        path: 'product/index',
        component: () => import('@/views/product/index'),
        name: 'Product',
        meta: { title: '会员套餐管理' }
      },
      {
        path: 'rights-package/index',
        component: () => import('@/views/rights-package/index'),
        name: 'RightsPackage',
        meta: { title: '权益包管理' }
      },
      {
        path: 'rights',
        component: APP,
        meta: { title: '权益管理' },
        children: [
          {
            path: 'index',
            component: () => import('@/views/rights/index'),
            name: 'RightsIndex',
            meta: { title: '权益列表' }
          },
          {
            path: 'class',
            component: () => import('@/views/rights/class'),
            name: 'RightsClass',
            meta: { title: '权益分类' }
          }
        ]
      },
      {
        path: 'addition',
        component: APP,
        meta: { title: '加购管理' },
        children: [
          {
            path: 'fnid',
            component: () => import('@/views/addition/fn-id'),
            name: 'AdditionFnID',
            meta: { title: '功能ID管理' }
          },
          {
            path: 'uselimit',
            component: () => import('@/views/addition/use-limit'),
            name: 'AdditionUseLimit',
            meta: { title: '消耗上限管理' }
          },
          {
            path: 'formula',
            component: () => import('@/views/addition/formula'),
            name: 'ChargeFormula',
            meta: { title: '计费价格' }
          },
          {
            path: 'package',
            component: () => import('@/views/addition/package'),
            name: 'AdditionPackage',
            meta: { title: '加购包' }
          },
          {
            path: 'product',
            component: () => import('@/views/product/index'),
            name: 'AdditionProduct',
            meta: { title: '会员套餐管理' }
          },
          {
            path: 'detail',
            component: () => import('@/views/addition/detail'),
            name: 'AdditionDetail',
            meta: { title: '加购明细管理' }
          }
        ]
      },
      {
        path: 'exchangecode/list',
        component: () => import('@/views/exchange-code/index'),
        name: 'ExchangeCodeList',
        meta: { title: '兑换码管理' }
      },
      {
        path: 'experience/list',
        component: () => import('@/views/experience/index'),
        name: 'ExperienceList',
        meta: { title: '体验券管理' }
      },
      {
        path: 'coupon/list',
        component: () => import('@/views/coupon/index'),
        name: 'CouponList',
        meta: { title: '优惠券管理' }
      },
      {
        path: 'coupon/report/:coupon_id',
        component: () => import('@/views/coupon/report'),
        name: 'CouponReport',
        meta: { title: '优惠券统计' }
      },
      {
        path: 'invite/list',
        component: () => import('@/views/invite/index'),
        name: 'InviteManage',
        meta: { title: '邀请码管理' }
      },

      {
        path: 'activity-mg/index',
        component: () => import('@/views/activity-mg/index'),
        name: 'ActivityMg',
        meta: { title: '活动管理' }
      },
      {
        path: 'reward-manage/index',
        component: () => import('@/views/reward-manage/index'),
        name: 'RewardManage',
        meta: { title: '奖品管理' }
      },
      {
        path: 'user-clustering/index',
        component: () => import('@/views/user-clustering/index'),
        name: 'UserClustering',
        meta: { title: '用户分群管理' }
      },

      {
        path: 'recharge',
        component: APP,
        name: 'RechargeManage',
        redirect: '/recharge/zb',
        meta: { title: '充值管理' },
        children: [
          {
            path: 'zb',
            component: () => import('@/views/recharge/zb'),
            name: 'RechargeZb',
            meta: { title: '智币充值' }
          },
          {
            path: 'price',
            component: () => import('@/views/recharge/price'),
            name: 'ResourcePrice',
            meta: { title: '功能定价' }
          },
          {
            path: 'order',
            component: () => import('@/views/recharge/order'),
            name: 'RechargeOrder',
            meta: { title: '订单列表' }
          }
        ]
      },
      {
        path: 'order/index',
        component: () => import('@/views/order/index'),
        name: 'Order',
        meta: { title: '订单列表' }
      },
      {
        path: 'agreement/index',
        component: () => import('@/views/agreement/index'),
        name: 'Agreement',
        meta: { title: '签约列表' }
      },
      {
        path: 'agreement/messages',
        component: () => import('@/views/agreement/messages'),
        name: 'AgreementMessages',
        meta: { title: '续费提醒' }
      },
      {
        path: '/financial/invoice',
        component: () => import('@/views/financial/invoice'),
        name: 'Invoice',
        meta: { title: '开票列表' }
      },
      {
        path: '/activity/index',
        component: () => import('@/views/activity/index'),
        name: 'Activity',
        meta: { title: '兑换中心' }
      },
      {
        path: '/activity/task',
        component: () => import('@/views/activity/task'),
        name: 'ActivityTask',
        meta: { title: '任务管理' }
      },
      {
        path: '/activity/exchange',
        component: () => import('@/views/activity/exchange'),
        name: 'ActivityExchange',
        meta: { title: '兑换管理' }
      },
      {
        path: 'ab',
        redirect: '/ab/index',
        component: APP,
        name: 'Ab',
        children: [
          {
            path: 'index',
            name: 'AbList',
            component: () => import('@/views/ab/list.vue'),
            meta: { title: '任务列表' }
          }
        ]
      },

      {
        path: 'operations',
        component: APP,
        name: 'OperationManage',
        redirect: '/operations/message',
        meta: { title: '运营管理' },
        children: [
          {
            path: 'message',
            component: () => import('@/views/operations/message'),
            name: 'OperationsMessage',
            meta: { title: '运营管理' }
          },
          {
            path: 'device',
            component: () => import('@/views/operations/device'),
            name: 'deviceManage',
            meta: { title: '设备限制' }
          }
        ]
      }
    ]
  }
]

/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [

]

const createRouter = () => new Router({
  mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export default router
